package com.kede.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kede.dto.AjaxMessage;
import com.kede.entity.AboutUs;
import com.kede.service.AboutUsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AboutUsController {

    @Autowired
    AboutUsService aboutUsService;

    @GetMapping("/aboutus")
    public String Index(Model model){
        AboutUs aboutUs = aboutUsService.getById(1);
        model.addAttribute("us", aboutUs);
        return "about";
    }

    @PostMapping("/saveus")
    public String saveusinfo(
            @RequestParam(value = "tel") String tel,
            @RequestParam(value = "address")String address,
            @RequestParam(value = "description")String description){

        AboutUs aboutUs = new AboutUs();
        aboutUs.setTel(tel);
        aboutUs.setAddress(address);
        aboutUs.setDescrption(description);

        aboutUsService.save(aboutUs);

        return "about";
    }
}
